# Author: williamjcm <w.jcm59@gmail.com>
# Contributor: mosra <mosra@centrum.cz>
# Based on the packages/archlinux/PKGBUILD file by mosra <mosra@centrum.cz> and the MSYS2/MinGW PKGBUILD templates

_realname=magnum-plugins
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=dev
pkgrel=1
pkgdesc="Plugins for the Magnum C++11/C++14 graphics engine"
arch=('any')
url="https://magnum.graphics/"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-magnum>=$pkgver"
         "${MINGW_PACKAGE_PREFIX}-assimp"
         "${MINGW_PACKAGE_PREFIX}-devil"
         "${MINGW_PACKAGE_PREFIX}-faad2"
         "${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-glslang"
         "${MINGW_PACKAGE_PREFIX}-harfbuzz"
         "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-openexr"
         "${MINGW_PACKAGE_PREFIX}-spirv-tools"
         "${MINGW_PACKAGE_PREFIX}-libwebp")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-ninja")
options=('!strip')

_rootdir=$startdir/../../

build() {
    mkdir -p "$_rootdir/build-${CARCH}"
    cd "$_rootdir/build-${CARCH}"

    MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
        ${MINGW_PREFIX}/bin/cmake .. \
            -G'Ninja' \
            -DCMAKE_BUILD_TYPE=Debug \
            -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
            -DMAGNUM_WITH_ASSIMPIMPORTER=ON \
            -DMAGNUM_WITH_ASTCIMPORTER=ON \
            -DMAGNUM_WITH_BASISIMAGECONVERTER=OFF \
            -DMAGNUM_WITH_BASISIMPORTER=OFF \
            -DMAGNUM_WITH_BCDECIMAGECONVERTER=ON \
            -DMAGNUM_WITH_CGLTFIMPORTER=ON \
            -DMAGNUM_WITH_DDSIMPORTER=ON \
            -DMAGNUM_WITH_DEVILIMAGEIMPORTER=ON \
            -DMAGNUM_WITH_DRFLACAUDIOIMPORTER=ON \
            -DMAGNUM_WITH_DRMP3AUDIOIMPORTER=ON \
            -DMAGNUM_WITH_DRWAVAUDIOIMPORTER=ON \
            -DMAGNUM_WITH_ETCDECIMAGECONVERTER=ON \
            -DMAGNUM_WITH_FAAD2AUDIOIMPORTER=ON \
            -DMAGNUM_WITH_FREETYPEFONT=ON \
            -DMAGNUM_WITH_GLSLANGSHADERCONVERTER=ON \
            -DMAGNUM_WITH_GLTFIMPORTER=ON \
            -DMAGNUM_WITH_GLTFSCENECONVERTER=ON \
            -DMAGNUM_WITH_HARFBUZZFONT=ON \
            -DMAGNUM_WITH_ICOIMPORTER=ON \
            -DMAGNUM_WITH_JPEGIMAGECONVERTER=ON \
            -DMAGNUM_WITH_JPEGIMPORTER=ON \
            -DMAGNUM_WITH_KTXIMAGECONVERTER=ON \
            -DMAGNUM_WITH_KTXIMPORTER=ON \
            -DMAGNUM_WITH_LUNASVGIMPORTER=OFF \
            -DMAGNUM_WITH_MESHOPTIMIZERSCENECONVERTER=OFF \
            -DMAGNUM_WITH_MINIEXRIMAGECONVERTER=ON \
            -DMAGNUM_WITH_OPENEXRIMAGECONVERTER=ON \
            -DMAGNUM_WITH_OPENEXRIMPORTER=ON \
            -DMAGNUM_WITH_OPENGEXIMPORTER=ON \
            -DMAGNUM_WITH_PLUTOSVGIMPORTER=OFF \
            -DMAGNUM_WITH_PNGIMAGECONVERTER=ON \
            -DMAGNUM_WITH_PNGIMPORTER=ON \
            -DMAGNUM_WITH_PRIMITIVEIMPORTER=ON \
            -DMAGNUM_WITH_RESVGIMPORTER=OFF \
            -DMAGNUM_WITH_SPIRVTOOLSSHADERCONVERTER=ON \
            -DMAGNUM_WITH_SPNGIMPORTER=OFF \
            -DMAGNUM_WITH_STANFORDIMPORTER=ON \
            -DMAGNUM_WITH_STANFORDSCENECONVERTER=ON \
            -DMAGNUM_WITH_STBDXTIMAGECONVERTER=ON \
            -DMAGNUM_WITH_STBIMAGECONVERTER=ON \
            -DMAGNUM_WITH_STBIMAGEIMPORTER=ON \
            -DMAGNUM_WITH_STBRESIZEIMAGECONVERTER=ON \
            -DMAGNUM_WITH_STBTRUETYPEFONT=ON \
            -DMAGNUM_WITH_STBVORBISAUDIOIMPORTER=ON \
            -DMAGNUM_WITH_STLIMPORTER=ON \
            -DMAGNUM_WITH_TINYGLTFIMPORTER=ON \
            -DMAGNUM_WITH_UFBXIMPORTER=ON \
            -DMAGNUM_WITH_WEBPIMAGECONVERTER=ON \
            -DMAGNUM_WITH_WEBPIMPORTER=ON
    ninja
}

package() {
    cd "$_rootdir/build-${CARCH}"
    DESTDIR="${pkgdir}" ninja install
}
